IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[DeleteProtocolVersionQuestionnaireAnswerMap]') AND objectproperty(id, N'IsProcedure') = 1)
BEGIN
	DROP PROCEDURE [dbo].[DeleteProtocolVersionQuestionnaireAnswerMap]
END
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE dbo.[DeleteProtocolVersionQuestionnaireAnswerMap]
(
	@questionnaireAnswerid INT,
	@protocolVersionId INT
)
AS
BEGIN
	SET NOCOUNT ON

	
	BEGIN
		
		DELETE FROM ProtocolVersion_QuestionnaireAnswer_Map 
		WHERE ProtocolVersionId = @protocolVersionId
		AND QuestionnaireAnswerId = @questionnaireAnswerid
	
		IF @@ERROR <> 0 GOTO ERROR_HANDLER	
		
		
		RETURN

	END
		
	ERROR_HANDLER:
		RAISERROR('Unable to delete the mapping between ProtocolVersion and QuestionnaireAnswer', 16, 1)
		RETURN
		

	SET NOCOUNT OFF
END
GO

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO